<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

/**
 * Class FamiliesMoneyRecord
 *
 * @property int $id
 * @property int|null $pay_type
 * @property int|null $families_id
 * @property int|null $order_id
 * @property int|null $worker_id
 * @property int|null $branch_id
 * @property int|null $interest_id
 * @property int|null $oa_id
 * @property float|null $money
 * @property float|null $course_money
 * @property int|null $type
 * @property int|null $status
 * @property Carbon|null $real_time
 * @property Carbon|null $create_time
 * @property Carbon|null $update_time
 *
 * @property WorkingFamily|null $working_family
 * @property Order|null $order
 *
 * @package App\Models
 */
class FamiliesMoneyRecord extends Model
{
	protected $table = 'families_money_record';

	protected $casts = [
		'pay_type' => 'int',
		'families_id' => 'int',
		'order_id' => 'int',
		'worker_id' => 'int',
		'branch_id' => 'int',
		'interest_id' => 'int',
		'oa_id' => 'int',
		'money' => 'float',
		'course_money' => 'float',
		'type' => 'int',
		'status' => 'int'
	];

	protected $dates = [
		'real_time'
	];

	protected $fillable = [
		'pay_type',
		'families_id',
		'order_id',
		'worker_id',
		'branch_id',
		'interest_id',
		'oa_id',
		'money',
		'course_money',
		'type',
		'status',
		'real_time'
	];

    public function working_family()
    {
        return $this->belongsTo(WorkingFamily::class, 'families_id');
    }

    public function order()
    {
        return $this->belongsTo(Order::class);
    }

    public function oa_records()
    {
        return $this->hasMany(OaRecord::class, 'finance_id');
    }
}
